<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="所属科室" prop="deptId">
        <el-select
          v-model="queryParams.deptId"
          placeholder="所属科室"
          clearable
        >
          <el-option
            v-for="dict in dict.type.sys_patinte_dept"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="患者名称" prop="patientName">
        <el-input
          v-model="queryParams.patientName"
          placeholder="请输入系统模块"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="挂号类型" prop="regName">
        <el-select
          v-model="queryParams.registerName"
          placeholder="操作类型"
          clearable
        >
          <el-option
            v-for="dict in dict.type.sys_register_name"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="挂号时段" prop="register_time">
        <el-select
          v-model="queryParams.register_time"
          placeholder="操作类型"
          clearable
        >
          <el-option
            v-for="dict in dict.type.vis_show_time"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="挂号状态" prop="register_status">
        <el-select
          v-model="queryParams.register_status"
          placeholder="操作类型"
          clearable
        >
          <el-option
            v-for="dict in dict.type.sys_reg_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="日期选择" prop="register_date">
        <el-date-picker
          v-model="queryParams.register_date"
          format="yyyy-MM-dd"
          value-format="yyyy-MM-dd"
          style="width: 100%"
          placeholder="请选择日期选择"
          clearable></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search"  @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh"  @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>


    <el-table v-loading="loading" :data="list" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="患者姓名" align="center" prop="patientName" />
      <el-table-column label="挂号编号" align="center" prop="deptId" />
      <el-table-column label="接诊医生" align="center" prop="doctorName" />
      <el-table-column label="挂号费用" align="center" prop="registerPrice" />
      <el-table-column label="流水编号" align="center" prop="regId" />
      <el-table-column label="状态" align="center" prop="status" width="100">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.vis_reg_status" :value="scope.row.status"/>
        </template>
      </el-table-column>
      <el-table-column label="就诊日期" align="center" prop="regTime" :show-overflow-tooltip="true" >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.regTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="挂号类型" align="center" prop="regName" :show-overflow-tooltip="true" />
      <el-table-column label="挂号时段" align="center" prop="regInterval" :show-overflow-tooltip="true">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.vis_show_time" :value="scope.row.regInterval"/>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

  </div>
</template>

<script>
    import {listShow,listDept,listRegister} from "@/api/vis/show/";
    export default {
        name: "Operlog",
        dicts: ['vis_reg_status', 'sys_patinte_dept','sys_register_name',
            'vis_show_time','sys_reg_status'],
        data() {
            return {
                //挂号状态
                registerStatus: [],
                //挂号时段
                registerTime: [],
                //查询挂号名称
                registerLists: [],
                //查询科室下拉框内容
                deptLists: [],
                // 遮罩层
                loading: true,
                // 选中数组
                ids: [],
                // 非多个禁用
                multiple: true,
                // 显示搜索条件
                showSearch: true,
                // 总条数
                total: 0,
                // 表格数据
                list: [],
                // 是否显示弹出层
                open: false,
                // 类型数据字典
                typeOptions: [],
                // 类型数据字典
                statusOptions: [],
                // 日期范围
                dateRange: '2021-09-28',
                // 表单参数
                form: {},
                // 查询参数
                queryParams: {
                    pageNum: 1,
                    pageSize: 10,
                    title: undefined,
                    deptId: undefined,
                    registerName: undefined,
                    register_time: undefined,
                    register_status: undefined,
                    register_date: undefined,

                }
            };
        },
        created() {
            this.listDept();
            this.listRegister();
            listShow().then(res=>{
                // console.log(res);
                this.list=res;
                this.total=res.total;
                this.loading=false;
            })
        },
        methods: {

            //收费与颓废按钮的设置
            setStatus(registerId){
                console.log("xiugai:"+registerId)
                setStatusa(registerId).then(response => {
                    if (response>0){
                        this.getList();
                    }
                });
            },

            //将展示的状态1查询为‘正常’
            parseTimea(a){
                if (a=='0'){
                    return '未就诊';
                }else if (a=='1'){
                    return '待就诊';
                }else if (a=='2'){
                    return '正在就诊';
                }else if (a=='3'){
                    return '就诊完成';
                }

            },
            /** 查询挂号类型下拉框 */
            listRegister() {
                this.loading = true;
                listRegister().then(response => {
                        this.registerLists = response;
                    }
                );
            },
            /** 查询科室下拉框 */
            listDept() {
                this.loading = true;
                listDept().then(response => {
                        this.deptLists = response;
                    }
                );
            },

            /** 搜索按钮操作 */
            handleQuery() {
                this.queryParams.pageNum = 1;
                this.listShow();
            },
            /** 重置按钮操作 */
            resetQuery() {
                this.dateRange = [];
                this.resetForm("queryForm");
                this.handleQuery();
            },
            // 多选框选中数据
            handleSelectionChange(selection) {
                this.ids = selection.map(item => item.register_id)
                this.multiple = !selection.length
            },
        }
    };
</script>

